package com.myproject.mall.domain.dto;

import com.myproject.mall.domain.entity.Shop;
import com.myproject.mall.domain.entity.User;
import com.myproject.mall.domain.enums.ShopStatus;
import lombok.Data;

import java.time.LocalDateTime;

@Data
public class ShopDTO {
    private Long id;
    private String title;
    private String description;
    private String poster;
    private String address;
    private ShopStatus status;
    private Integer fans;

    private String userId;
    private String username;

    private LocalDateTime createTime;
    private LocalDateTime updateTime;


    public static ShopDTO of(Shop shop, User user){
        ShopDTO shopDTO = new ShopDTO();
        shopDTO.setId(shop.getId());
        shopDTO.setTitle(shop.getTitle());
        shopDTO.setDescription(shop.getDescription());
        shopDTO.setPoster(shop.getPoster());
        shopDTO.setAddress(shop.getAddress());
        shopDTO.setStatus(shop.getStatus());
        shopDTO.setFans(shop.getFans());
        shopDTO.setUserId(user.getId());
        shopDTO.setUsername(user.getUsername());

        return shopDTO;
    }
}
